﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace CMD.BAL.MISC
{
    public class Utilities
    {
        public static DateTime NowWithENFormat()
        {
            CultureInfo culture = new CultureInfo("en-US");
            DateTime cycle;

            string mes = DateTime.Now.Month.ToString();
            string dia = DateTime.Now.Day.ToString();

            if (mes.Length == 1)
                mes = "0" + DateTime.Now.Month.ToString();
            if (dia.Length == 1)
                dia = "0" + DateTime.Now.Day.ToString();

            string sFecha = DateTime.Now.Year.ToString() + "/" + mes + "/" + dia;            
            cycle = Convert.ToDateTime(sFecha, culture);

            return cycle;
        }

        public static string NowWithENFormat(string fecha)
        {
            IFormatProvider culture = new CultureInfo("en-US", true);
            DateTime cycle;

            DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
            dtfi.ShortDatePattern = "yyyyMMdd";
            dtfi.LongDatePattern = "dddd, yyyy MMMM dd";

            string sFecha = fecha.Replace("/","");
            //cycle = DateTime.ParseExact(sFecha, "d", dtfi);     //Convert.ToDateTime(sFecha, dtfi); //
            
            return sFecha;
            //return cycle;
        }

    }
}
